﻿package mortal.game.view.mining.panel
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.pageSelect.*;
    import mortal.game.view.mining.render.*;

    public class MiningRefleshPanel extends BaseWindow
    {
        private var _bg:ScaleBitmap;
        private var _list:GTileList;
        private var _page:PageSelecter;
        private var _datas:Array;
        private const PageNum:int = 5;
        private var _titleBg3:ScaleBitmap;
        private var _title3:GBitmap;
        private var _listBeRefresh:GTileList;

        public function MiningRefleshPanel()
        {
            super.layer = LayerManager.windowLayer;
            this.setSize(289, 586);
            this.title = Language.getString(21033);
            return;
        }// end function

        public function updateAllInfos() : void
        {
            this.updateList();
            this.updateBeRefreshedInfos();
            return;
        }// end function

        private function updateBeRefreshedInfos() : void
        {
            this._listBeRefresh.dataProvider = Cache.instance.mining.getBeRefreshedDataProvider();
            this._listBeRefresh.drawNow();
            return;
        }// end function

        private function updateList() : void
        {
            if (this._page == null)
            {
                return;
            }
            this._datas = Cache.instance.mining.getMiningMembersDataArr();
            this._page.maxPage = Math.max(Math.ceil(this._datas.length / this.PageNum), 1);
            this.onPageChange(null);
            return;
        }// end function

        private function onPageChange(param1) : void
        {
            var _loc_7:MiningRefreshStartData = null;
            var _loc_2:* = this._page.currentPage;
            var _loc_3:* = (_loc_2 - 1) * this.PageNum;
            var _loc_4:* = Math.min(_loc_2 * this.PageNum, this._datas.length);
            var _loc_5:* = new DataProvider();
            var _loc_6:* = _loc_3;
            while (_loc_6 < _loc_4)
            {
                
                _loc_7 = new MiningRefreshStartData();
                _loc_7.info = this._datas[_loc_6];
                _loc_7.isBlack = _loc_6 % 2 == 0;
                _loc_5.addItem(_loc_7);
                _loc_6++;
            }
            this._list.dataProvider = _loc_5;
            this._list.drawNow();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.bg(9, 30, 275, 558, this);
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.color = 16252126;
            this._list = UIFactory.tileList(10, 32, 275, 268, this);
            this._list.setStyle("cellRenderer", MiningRefleshStarRender);
            this._list.rowHeight = 53;
            this._list.columnWidth = 380;
            this._page = UIFactory.pageSelecter(78, 305, this, PageSelecter.CompleteMode);
            this._titleBg3 = UIFactory.bg(10, 340, 275, 24, this, ImagesConst.RegionTitleBg);
            this._title3 = UIFactory.gBitmap(null, 86, this._titleBg3.y + 3, this);
            this._listBeRefresh = UIFactory.tileList(this._titleBg3.x, this._titleBg3.y + 26, 257, 214, this);
            this._listBeRefresh.setStyle("cellRenderer", MiningBeRefleshRender);
            this._listBeRefresh.rowHeight = 49;
            this._listBeRefresh.columnWidth = 250;
            this._page.configEventListener(Event.CHANGE, this.onPageChange);
            LoaderHelp.addResCallBack(ResFileConst.mining, this.miningResGot);
            return;
        }// end function

        private function miningResGot() : void
        {
            if (isDisposed)
            {
                return;
            }
            this._title3.bitmapData = GlobalClass.getBitmapData(ImagesConst.Mining_jrbzgyqk);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg.dispose(param1);
            this._bg = null;
            this._list.dispose(param1);
            this._list = null;
            this._page.dispose(param1);
            this._page = null;
            this._listBeRefresh.dispose(param1);
            this._listBeRefresh = null;
            this._titleBg3.dispose(param1);
            this._titleBg3 = null;
            this._title3.dispose(param1);
            this._title3 = null;
            return;
        }// end function

    }
}
